package com.ruoyi.business.acc.service.impl;

import java.util.List;

import com.ruoyi.frame.util.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.business.acc.mapper.AccMapper;
import com.ruoyi.business.acc.domain.Acc;
import com.ruoyi.business.acc.service.IAccService;
import com.ruoyi.common.core.text.Convert;

/**
 * 账户Service业务层处理
 *
 * @author zengxiangjiang
 * @date 2022-03-15
 */
@Service
public class AccServiceImpl implements IAccService
{
    @Autowired
    private AccMapper accMapper;

    /**
     * 查询账户
     *
     * @param merId 账户主键
     * @return 账户
     */
    @Override
    public Acc selectAccByMerId(String merId)
    {
//        return accMapper.selectByPrimaryKey(merId);
        return accMapper.selectAccByMerId(merId);
    }

    /**
     * 查询账户列表
     *
     * @param acc 账户
     * @return 账户
     */
    @Override
    public List<Acc> selectAccList(Acc acc)
    {
        return accMapper.selectAccList(acc);
    }

    /**
     * 新增账户
     *
     * @param acc 账户
     * @return 结果
     */
    @Override
    public int insertAcc(Acc acc)
    {
        acc.setMerId(IdUtils.getSnowflakeIdStr());
        return accMapper.insertAcc(acc);
    }

    /**
     * 修改账户
     *
     * @param acc 账户
     * @return 结果
     */
    @Override
    public int updateAcc(Acc acc)
    {
        return accMapper.updateAcc(acc);
    }

    /**
     * 批量删除账户
     *
     * @param merIds 需要删除的账户主键
     * @return 结果
     */
    @Override
    public int deleteAccByMerIds(String merIds)
    {
        return accMapper.deleteAccByMerIds(Convert.toStrArray(merIds));
    }

    /**
     * 删除账户信息
     *
     * @param merId 账户主键
     * @return 结果
     */
    @Override
    public int deleteAccByMerId(String merId)
    {
        return accMapper.deleteAccByMerId(merId);
    }
}
